/**
* Created by wl
* 项目管理>持有中-详情页-编辑投资服务信息
*/
<template>
    <div>
        <div class="ca-title">
            <el-row class="after-row ca-p-10">
                <el-col :span="20">
                    <div class="after-form-input">
                        <div class="alarm-time">预警时间：
                            <span>{{alarmInfo.groupDate}}</span>
                            <el-button type="text" size="small">{{alarmInfo.itemFinanceManagement.teamProposal == '' ? '未处理' : alarmInfo.itemFinanceManagement.holdStrategy == '' ? '未处理' : '已处理'}}</el-button>
                        </div>
                    </div>
                </el-col>
                <el-col :span="4" class="align-r ca-pull-right">
                    <el-button type="primary" @click="save" size="small">保存</el-button>
                    <el-button @click="close" size="small">取消</el-button>
                </el-col>
            </el-row>
        </div>
        <el-form>
            <el-row class="after-row ca-p-10">
                <el-col :span="4" class="ca-align-left ca-m-l-30" >
                    <span>项目组建议持有策略：</span>
                </el-col>
                <el-col :span="6">
                    <el-select placeholder="请选择" v-model="remindInfo.teamProposal">
                        <el-option v-for="item in investStrategyType" :label="item.name" :value="item.id"
                                :key="item.id"></el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="after-row ca-p-10">
                <el-col :span="4" class="ca-align-left ca-m-l-30"><span>投后建议持有策略：</span></el-col>
                <el-col :span="6">
                    <el-select placeholder="请选择" v-model="remindInfo.holdStrategy">
                        <el-option v-for="item in investStrategyType" :label="item.name" :value="item.id"
                                :key="item.id"></el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="after-row ca-p-10">
                <el-col :span="2" class="ca-align-left ca-m-l-30" ><span>备注：</span></el-col>
                <el-col :span="18">
                    <el-input type="textarea" :rows="4" v-model="remindInfo.note" :maxlength="3000"></el-input>
                </el-col>
            </el-row>
            <el-row class="after-row">
                <el-col :span="24">
                    <div class="after-form-list alarm-table">
                        <table class="ca-table">
                            <thead>
                            <tr>
                                <th width="20%">预警类型</th>
                                <th width="20%">规则</th>
                                <th>公式</th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr v-for="(itemInfo, ind) in alarmInfo.itemFinanceRemindResults" :key="ind">
                                    <td width="7%">
                                        <span >{{itemInfo.remindLevel == 1 ? '关注' : '预警' }}</span>
                                    </td>
                                    <td width="10%">{{itemInfo.title}}</td>
                                    <td v-if="itemInfo.symbol != '介于'">{{itemInfo.remindKey}}{{itemInfo.symbol}}{{itemInfo.threshold}}</td>
                                    <td v-else>{{itemInfo.remindKey}}{{itemInfo.symbol}}{{itemInfo.threshold}}--{{itemInfo.threshold2}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    export default {
        data() {
            return {
                formLabelWidth: '90px',
                investStrategyType: this.$store.state.user.dictionaryMap.investStrategyType, //持有策略
                disposalMethods: this.$store.state.user.dictionaryMap.disposalMethods, //处置方式
                remindInfo: {
                    groupDate: this.alarmInfo.groupDate,
                    holdStrategy: null, //投后建议持有策略：1:继续持有 2：尽快处置 3：择机减持 4：择机增持
                    itemId: this.$route.params.itemId,
                    // managementId: '', //处置ID
                    note: '', //备注
                    teamProposal: null //项目组建议持有策略：1:继续持有 2：尽快处置 3：择机减持 4：择机增持
                }
            }
        },
        watch: {
        },
        props: {
            alarmInfo: {
                type: Object,
                default: function () {
                    return {};
                }
            },
            index: {
                type: Number,
                default: function () {
                    return 0;
                }
            }
        },
        mounted() {
            this.remindInfo = this.alarmInfo.itemFinanceManagement
            if (this.remindInfo.holdStrategy === null) {
                this.remindInfo.holdStrategy = ''
            } else {
                this.remindInfo.holdStrategy = this.alarmInfo.itemFinanceManagement.holdStrategy.toString()
            }
            if (this.remindInfo.teamProposal === null) {
                this.remindInfo.teamProposal = ''
            } else {
                this.remindInfo.teamProposal = this.alarmInfo.itemFinanceManagement.teamProposal.toString()
            }
        },
        methods: {
            save() {
                let query = {
                    groupDate: this.alarmInfo.groupDate,
                    holdStrategy: this.remindInfo.holdStrategy === '' ? null : Number(this.remindInfo.holdStrategy), //投后建议持有策略：1:继续持有 2：尽快处置 3：择机减持 4：择机增持
                    itemId: this.$route.params.itemId,
                    managementId: this.remindInfo.managementId, //处置ID
                    note: this.remindInfo.note, //备注
                    teamProposal: this.remindInfo.teamProposal === '' ? null : Number(this.remindInfo.teamProposal), //项目组建议持有策略：1:继续持有 2：尽快处置 3：择机减持 4：择机增持
                }
                apiHttp(api.SAVE_ALARM, query).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.$message({
                            message: '数据保存成功！',
                            type: 'success',
                            center: true
                        });
                        this.$emit('save')
                    }
                })
            },
            close() {
                this.$emit('close', this.index)
            }
        },
        components: {
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-col-4 {
    line-height: 35px;
}
.alarm-time{
    font-size:18px;
    color:#333;
    margin-top: 10px;
    margin-left: 30px;
    span{
        font-size:14px;
        color:#999;
        margin-right:20px;
    }
}
.ca-right {
    display: inline-block;
}
.ca-pull-right {
    float: right;
    margin-top: 10px;
}
.ca-m-l-30 {
    margin-left: 30px;
}
.after-form-list {
    width: 90%;
    margin: 0 auto;
}
.ca-table {
    width: 100%;
    border: #dbe3ea 1px solid;
    border-collapse: collapse;
    margin-top: 20px;
    margin-bottom: 20px;
}
</style>